package com.polaris.live.im.db.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.polaris.live.im.db.entity.TrackPushEntity

/**
 * 埋点保存
 *
 * @author Created by lucas on 2024/1/1 07:42
 * @since 1.0.0
 */
@Dao
interface TrackPushEntityDao {

    /**
     * 保存埋点
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(entity: TrackPushEntity): Long

    /**
     * 查询埋点
     */
    @Query(
        """
        select * 
        from track_push
        limit :limit
    """
    )
    suspend fun findTraces(limit: Int): List<TrackPushEntity>

    /**
     * 删除埋点
     */
    @Query("""
        delete from track_push
        where event_id in (:eventIds)
    """)
    suspend fun deleteByEventIds(eventIds: Collection<String>)

}